package com.hnevc.xiewanguang;
/**
 *
 *
 * String类当中得常用方法
 *
 */
public class Example02 {
    public static void main(String[] args) {
        String phone = "13187041108";
        System.out.println("获取字符串的长度：" + phone.length());
        System.out.println("获取字符串中7第一次出现的位置" + phone.indexOf("7"));
        System.out.println("获取字符串7最后一次出现的位置" + phone.lastIndexOf("7"));
        System.out.println("获取字符串第一次出现的位置" + phone.indexOf("10"));
        System.out.println("获取字符串最后一次出现的位置" + phone.lastIndexOf("10"));

        String str = " abca bcabe";
        System.out.println(str.length());
        System.out.println(str.replace(" ","|"));
        System.out.println(str.trim());

        String str1 = "xiewenguang@qq.com";
        System.out.println("判断邮箱是否以姓名拼音开头：" +  str1.startsWith("xiewenguang"));
        System.out.println("判断邮箱是否以.com结尾：" + str1.startsWith(".com"));
        System.out.println("判断邮箱是否含@符号" + str1.contains("@"));
        String str2 = "";
        String str3 = "";
        System.out.println("判断str1是否为空：" + str1.isEmpty());
        System.out.println("判断str2是否为空：" + str2.isEmpty());
        System.out.println("判断str1和str2是否相等" + str2.equals(str3));
        String str4 = "abc";
        String str5 ="ABC";
        System.out.println("str4转换为大写" + str4.toUpperCase());
        System.out.println("str5转换为小写" +str5.toUpperCase());
        //13187041108
        System.out.println("手机号后四位" + phone.substring(7));
        System.out.println("手机号中间四位" + phone.substring(3,7));


    }

}
